<!DOCTYPE html >
<html>
<head>
    <link rel="stylesheet" href="demos.css" type="text/css" media="screen" />
    
    <script src="../libraries/RGraph.common.core.js" ></script>
    <script src="../libraries/RGraph.common.dynamic.js" ></script>
    <script src="../libraries/RGraph.common.tooltips.js" ></script>
    <script src="../libraries/RGraph.drawing.rect.js" ></script>
    <script src="../libraries/RGraph.bar.js" ></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <!--[if lt IE 9]><script src="../excanvas/excanvas.js"></script><![endif]-->
    
    <title>A stacked bar chart with clickable "whole bars"</title>
    
    <meta name="description" content="By using the drawing API rect object you can make the whole bar of a stacked Bar chart clickable - allowing yout 'group' tooltips etc" />
     
</head>
<body>
        
    <h1>A stacked bar chart with clickable "whole bars"</h1>
    
    <p>
        By using the drawing API rect object you can make the whole bar of a stacked Bar chart clickable - allowing you to 'group' tooltips etc
    </p>

    <canvas id="cvs" width="700" height="350">[No canvas support]</canvas>

    <script>
        $(document).ready(function ()
        {
            var tooltips = ['John results','James results','Freds results','Luke results','Luis results'];

            var bar = new RGraph.Bar({
                id: 'cvs',
                data: [[5.33,2.33,3.32],[3.42,2.23,4.23],[4.23,3.23,4.99], [7.99,2.98,2.35], [2.75,1.02,5.24]],
                options: {
                    labels: {
                        self: ['John','James','Fred','Luke','Luis'],
                        above: {
                            self: true,
                            decimals: 2
                        },
                    },
                    linewidth: 2,
                    strokestyle: 'white',
                    colors: ['Gradient(#4572A7:#66f)','Gradient(#AA4643:white)','Gradient(#89A54E:white)'],
                    shadow: {
                        offsetx: 1,
                        offsety: 1,
                        blur: 5
                    },
                    hmargin: 25,
                    gutter: {
                        left: 45
                    },
                    background: {
                        grid: {
                            vlines: false,
                            border: false
                        }
                    },
                    axis: {
                        color: '#ccc'
                    },
                    noyaxis: true,
                    grouping: 'stacked'
                }
            }).draw()
        
            for (var i=0; i<bar.coords2.length; ++i) {

                var x = bar.coords2[i][0][0];
                var y = bar.coords2[i][0][1];
                var w = bar.coords2[i][0][2];
                var h = bar.coords2[i][0][3] + bar.coords2[i][1][3] + bar.coords2[i][2][3]; // Sum up the heights of the bar segments

                var rect = new RGraph.Drawing.Rect({
                    id: 'cvs',
                    x: x,
                    y: y,
                    width: w,
                    height: h,
                    options: {
                        strokestyle: 'rgba(0,0,0,0)',
                        fillstyle: 'rgba(0,0,0,0)',
                        tooltips: [tooltips[i]],
                        highlight: {
                            stroke: 'rgba(0,0,0,0)'
                        }
                    }
                }).draw()
            }
        })
    </script>
    <p>
        <a href="./">&laquo; Back</a>
    </p>

</body>
</html>